home *** CD-ROM | disk | FTP | other *** search
- ' This simple macro opens an ASCII text file and draws either lines
- ' or curves based on the content of the file. It takes a variable
- ' number of coordinates for the line or curve based on the value in
- ' the file.
- '
- ' Dimension Arrays to hold points
- Dim xval(99)
- Dim yval(99)
- ' Open the File, (*\ denotes the DesignCAD directory)"
- Open "i", 1, "*\Sample Macros\Data.txt"
- ' Loop until the end of the file
- Do While NOT EOF(1)
- ' Get Header Line
- Input #1, Header$
- ' Determine Line or Curve
- Det$ = LEFT$(Header$, 1)
- ' Get Position of comma in line
- Comma$ = ","
- Pos = INSTR(Header$, Comma$)
- ' Do not include the comma in the retrieved #
- Pos = Pos + 1
- ' Get # of points in object,
- ' Change 2 below to 3 for lines for curve with over 99 points
- CurNum$ = MID$(Header$, pos, 2)
- ' Convert string to number
- CurNum = CurNum$
- ' Loop to get Points out of the ASCII file into an Array
- for a = 1 to CurNum
- Input #1, xone, yone
- xval(a) = xone
- yval(a) = yone
- next a
- ' Print Results of Array (for testing purposes only).
- for a = 1 to CurNum
- Temp$ = xval(a)
- Temp2$ = yval(a)
- ' Message Temp$," ",Temp2$
- next a
- ' If we're drawing a Curve
- if Det$ = "C" then
- ' Draw Curve with points
- >Curve
- {
- for a = 1 to CurNum
- <pointxyz [xval(a), yval(a), 0]
- next a
- }
- endif
- ' If we're drawing a Line
- if Det$ = "L" then
- ' Draw Line with points
- >Line
- {
- for a = 1 to CurNum
- <pointxyz [xval(a), yval(a), 0]
- next a
- }
- endif
- Loop
- ' Close File
- Close #1
-